﻿using Lk.Common.AttributeHelper;
using Lk.IRepositories;
using Lk.IServices;
using Lk.Model.Models;
using Lk.Services.Base;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using SqlSugar;

namespace Lk.Services
{
    public class UserService : BaseServices<users>, IUserService
    {
        private readonly IUserRepository _userRepository;

        public UserService(IUserRepository userRepository)
        {
            _userRepository = userRepository;
        }
        [Caching(AbsoluteExpiration = 10)]//增加特性
        public async Task<List<users>> GetList()
        {

            var result = await _userRepository.Query();
            return result;
        }


        public async Task<users> GetByName(string userName)
        {
            var result = await _userRepository.Query(s => s.user_name == userName);
            return result.FirstOrDefault();
        }

        public async Task Update(users user)
        {
            await _userRepository.Update(user);
        }
    }
}
